/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.app;

import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

public class CommonToolBar extends JToolBar{
//  private static final long serialVersionUID = 792559806321732694L;
  
  private JButton buttons[];
  public static final int NO_OF_BUTTONS = 8;

  public CommonToolBar() {
    // Create the toolbar
    super();

    buttons= new JButton[NO_OF_BUTTONS];

    // Create the buttons[ to populate it
    // Image dimension 16x16
    buttons[0] = new JButton(new ImageIcon("images/new.png"));
    buttons[1] = new JButton(new ImageIcon("images/open.png"));
    buttons[2] = new JButton(new ImageIcon("images/save.png"));
    buttons[3] = new JButton(new ImageIcon("images/copy.png"));
    buttons[4] = new JButton(new ImageIcon("images/cut.png"));
    buttons[5] = new JButton(new ImageIcon("images/paste.png"));
    buttons[6] = new JButton(new ImageIcon("images/zoomin.png"));
    buttons[7] = new JButton(new ImageIcon("images/zoomout.png"));

    //Set tooltips
    buttons[0].setToolTipText("New");
    buttons[1].setToolTipText("Open");
    buttons[2].setToolTipText("Save");
    buttons[3].setToolTipText("Copy");
    buttons[4].setToolTipText("Cut");
    buttons[5].setToolTipText("Paste");
    buttons[6].setToolTipText("Zoom In");
    buttons[7].setToolTipText("Zoom Out");

    // Add the buttons[ to the toolbar
    for (int i=0; i<NO_OF_BUTTONS; i++){
      if (i==3||i==6)
        addSeparator();
      add(buttons[i]);
    }
    //Set toolbar to not floatable - so that it can not be moved about
    //setFloatable(false);
  }

  public void addActionListeners(ActionListener listeners[]){
    int x = Math.min(listeners.length, NO_OF_BUTTONS);
    for (int i=0; i< x;i++){
      buttons[i].addActionListener(listeners[i]);
    }
  }
}
